<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>gymMain</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"
	media="all" />
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--slider-->
<link rel="stylesheet" href="../css/flexslider.css" type="text/css"
	media="all" />
<!-- jQuery -->
<!-- FlexSlider -->

<link rel="stylesheet" type="text/css"
	href="../bootstrap/bootstrap.4.1.0.css">
<script src="../bootstrap/jquery.3.2.1.min.js"></script>
<script src="../bootstrap/popper.12.5.min.js"></script>
<script src="../bootstrap/bootstrap.4.1.0.min.js"></script>

<script src="../vue/Vue.js"></script>
<script src="../vue/axios.js"></script>
<script type="text/javascript">
	$(function() {
		$("#header").load("../zlz/header.html");
		
	})
</script>
</head>
<body>
	<div id="app">
		<div id="header"></div>
		<h1 v-if="coaches.length==0" text-align="center">没有请求的人</h1>
		<table class="table table-bordered table-hover">
			<thead>
				<tr v-if="coaches.length!=0">
					<th>教练名</th>
					<th>课时单价</th>
					<th>同意</th>
					<th>拒绝</th>
				</tr>
				
			</thead>
			<tbody>
				<!-- <tr v-if="coaches.length==0" >
					暂时没有签约申请
				</tr> -->
				<tr v-for="coa in coaches" v-if="coa !=null">
					<td>{{coa.coach.nickname}}</td> 
					<td>{{coa.priceHour}}</td>
					<td>
						<button class="btn btn-outline-success" @click="agree(coa.userId)">同意</button>
					</td>
					
					<td>
						<button class="btn btn-outline-success" @click="refuse(coa.userId)">拒绝</button>
					</td>
				</tr>
			</tbody>
		</table>
	
	
		
		<div class="footer">
			<div class="wrap">
				<div class="section group">
					<div class="col_1_of_footer span_1_of_footer">
						<div class="location">
							<h3>地址</h3>
							<ul>
								<li>1-22-003-55,</li>
								<li>四川省成都市</li>
								<li>火车南站蜗牛hifit</li>
								<li>CHINA</li>
							</ul>
						</div>
					</div>
					<div class="col_1_of_footer span_1_of_footer">
						<h3>信息</h3>
						<p>hifit健身，创建于2005年，立足长三角，辐射全中国！专注健身15年，已发展成为中国大型直营健身连锁领跑者。截至2018年7月，hifit健身已拥有400+家签约及开业的直营门店。</p>
					</div>
					<div class="col_1_of_footer span_1_of_footer">
						<h3>品牌简介</h3>
						<div class="Testimonials_desc">
							<p>
								<span class="up"></span>hifit健身，立足长三角，专注健身14年，拥有400+家签约及开业的直营门店。累计发展会员人数300余万，每年新增约80万会员，每天约30万会员在全国各分店享受专业健身服务。<span
									class="down"><img src="" alt=""></span>
							</p>

						</div>
					</div>
					<div class="col_1_of_footer span_1_of_footer">
						<h3>联系我们</h3>
						<ul class="address">
							<li>蜗牛科技</li>
							<li><span>电话:</span> +86 132123456789</li>
							<li><span>座机:</span> +32 132 74895</li>
							<li><span>传真:</span> +69 320 832479</li>
						</ul>
					</div>
					<div class="clear"></div>
				</div>
			</div>
			<div class="copy-right">
				<div class="wrap">
					
			          <p class="copy">
					&copy; Copyright &copy; 2020.Cyh All rights reserved.
					</p>

				</div>
			</div>
		</div>
	</div>
	
</body>
<script type="text/javascript">
		var vm=new Vue({
			el:"#app",
			data:{
				coaches:[]
			},
			mounted(){
				axios.get("/gymInfo/myPreEmp")
					.then(res => {
						console.info(res.data);
						this.coaches = res.data;
					});
			},
			methods:{
				agree(userId){
					//先请求，后台先签约，后台成功了，前台才应该删除数据
					var params = new URLSearchParams();
					params.append("coachId",userId);
					axios.post("/gymInfo/SginCoach",params)
						.then(res => {
						console.info(res);
							if (res.data==1) {
								//alert("后台成功");
								for(var i=0;i<this.coaches.length;i++){
									coa = this.coaches[i];
									if (coa.userId==userId) {
										//删除记录   只需要删除数据，页面上的记录也会被删除掉
										this.coaches.splice(i,1);//从i的位置删除1个元素 包括i
										break;
									}
								} 
							}else{
								alert("后台没成功");
							}
						})
					
				},
				refuse(userId){
					//先请求，后台先签约，后台成功了，前台才应该删除数据
					var params = new URLSearchParams();
					params.append("coachId",userId);
					axios.post("/gymInfo/refuseCoach",params)
						.then(res => {
						console.info(res);
							if (res.data==1) {
								//alert("后台成功");
								for(var i=0;i<this.coaches.length;i++){
									coa = this.coaches[i];
									if (coa.userId==userId) {
										//删除记录   只需要删除数据，页面上的记录也会被删除掉
										this.coaches.splice(i,1);//从i的位置删除1个元素 包括i
										break;
									}
								} 
							}else{
								alert("后台没成功");
							}
						})
					
				}
				
			}
		});
	</script>
</html>



